home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Network Support Library
/
RoseWare - Network Support Library.iso
/
apidev
/
ipx751.arc
/
IPXUNIT.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1988-08-29
|
8KB
|
318 lines
Unit IPXUnit;
{ IPXUNIT.PAS - IPX/SPX Functions Unit 08-24-88 }
(*
Version 1.0 8-24-88 : Basic Unit Development / Prototyping
Version 1.1 8-26-88 : Implement SPX Functions
*)
Interface
Uses Dos;
Const
MaxAESEvents = 32;
IPXDataSeg : Word = 0; {Copy of this Unit's Data Segment base}
Type
IPXNetAddr = Array[1..4] of Byte;
IPXNodeAddr = Array[1..6] of Byte;
IPXAddress = Record
Network : IPXNetAddr;
Node : IPXNodeAddr;
Socket : Word;
End;
IPXHeaderRec = Record
CheckSum : Word;
PacketLen : Word;
TransCtrl : Byte;
PacketType : Byte;
DestAdd : IPXAddress;
SourceAdd : IPXAddress;
End;
ECBRec = Record
Link : Array[1..2] of Word;
ESRAddr : Array[1..2] of Word;
InUse : Byte;
CompCode : Byte;
Socket : Word;
IPXWork : Array[1..4] of Byte;
DriverWork : Array[1..12] of Byte;
ImmedAddr : IPXNodeAddr;
FragCount : Word;
End;
FragmentDesc = Record
FragAddr : Array[1..2] of Word;
FragLength : Word;
End;
AESRec = Record
Link : Array[1..2] of Word;
ESRAddr : Array[1..2] of Word;
InUse : Byte;
WorkSpace : Array[1..5] of Byte;
End;
SPXHeaderRec = Record
CheckSum : Word;
PacketLen : Word;
TransCtrl : Byte;
PacketType : Byte;
DestAdd : IPXAddress;
SourceAdd : IPXAddress;
ConnControl : Byte;
DataType : Byte;
SourceConnID: Word;
DestConnID : Word;
SeqNumber : Word;
AckNumber : Word;
AllocNumber : Word;
End;
Var
IPXResultCode : Byte; {All Result Codes returned here}
IPXTransTime : Word; {All Transport Times returned here}
AES_ECB : Array[1..MaxAESEvents] of AESRec;
Procedure IPXOpenSocket (OpenMode: Word; Var Socket: Word);
Procedure IPXCloseSocket (Socket: Word);
Procedure IPXGetTarget (Target: IPXAddress; Var LocalTarget: IPXNodeAddr);
Procedure IPXSendPacket (Var ECB: ECBRec);
Procedure IPXListenPacket (Var ECB: ECBRec);
Procedure IPXScheduleEvent (Var ECB: ECBRec; DelayTime: Word);
Procedure IPXCancelEvent (Var ECB: ECBRec);
Procedure IPXRelinquish;
Procedure IPXNotifyDisconnect (Target: IPXAddress);
Procedure AESScheduleEvent (Var AES: AESRec; DelayTime: Word);
Procedure AESCancelEvent (Var AES: AESRec);
Procedure AESStartEvent (EventNo,DelayTime: Word);
Procedure AESAbortEvent (EventNo: Word);
Function AESEventTrip (EventNo: Word): Boolean;
Implementation
{ * Local unit variables * }
Var
Regs : Registers;
Procedure ClearRegs;
Begin
FillChar(Regs,SizeOf(Regs),0);
End;
Procedure IPXOpenSocket (OpenMode: Word; Var Socket: Word);
Begin
ClearRegs;
If not (OpenMode in [0,$FF]) then {Invalid Open Mode}
Begin
IPXResultCode := 1;
Exit;
End;
Regs.Ax := OpenMode;
Regs.Bx := 0;
Regs.Dx := Swap(Socket);
Intr($7A,Regs);
If Socket=0 then Socket := Swap(Regs.Dx);
IPXResultCode := Lo(Regs.Ax);
End;
Procedure IPXCloseSocket (Socket: Word);
Begin
ClearRegs;
Regs.Bx := $0001;
Regs.Dx := Swap(Socket);
Intr($7A,Regs);
IPXResultCode := 0;
End;
Procedure IPXGetTarget (Target: IPXAddress; Var LocalTarget: IPXNodeAddr);
Begin
ClearRegs;
With Regs do
Begin
Bx := $0002;
Es := Seg(Target);
Si := Ofs(Target);
Di := Ofs(LocalTarget);
End;
Intr($7A,Regs);
IPXResultCode := Lo(Regs.Ax);
If IPXResultCode=0 then IPXTransTime := Regs.Cx;
End;
Procedure IPXSendPacket (Var ECB: ECBRec);
Begin
ClearRegs;
With Regs do
Begin
Bx := $0003;
Es := Seg(ECB);
Si := Ofs(ECB);
End;
Intr($7A,Regs);
IPXResultCode := 0;
End;
Procedure IPXListenPacket (Var ECB: ECBRec);
Begin
ClearRegs;
With Regs do
Begin
Bx := $0004;
Es := Seg(ECB);
Si := Ofs(ECB);
End;
Intr($7A,Regs);
IPXResultCode := 0;
End;
Procedure IPXScheduleEvent (Var ECB: ECBRec; DelayTime: Word);
Begin
ClearRegs;
With Regs do
Begin
Ax := DelayTime;
Bx := $0005;
Es := Seg(ECB);
Si := Ofs(ECB);
End;
Intr($7A,Regs);
IPXResultCode := 0;
End;
Procedure IPXCancelEvent (Var ECB: ECBRec);
Begin
ClearRegs;
With Regs do
Begin
Bx := $0006;
Es := Seg(ECB);
Si := Ofs(ECB);
End;
Intr($7A,Regs);
IPXResultCode := Lo(Regs.Ax);
End;
Procedure IPXRelinquish;
Begin
ClearRegs;
Regs.Bx := $000A;
Intr($7A,Regs);
End;
Procedure IPXNotifyDisconnect (Target: IPXAddress);
Begin
ClearRegs;
With Regs do
Begin
Bx := $000B;
Es := Seg(Target);
Si := Ofs(Target);
End;
Intr($7A,Regs);
IPXResultCode := 0;
End;
Procedure AESScheduleEvent (Var AES: AESRec; DelayTime: Word);
Begin
ClearRegs;
With Regs do
Begin
Ax := DelayTime;
Bx := $0007;
Es := Seg(AES);
Si := Ofs(AES);
End;
Intr($7A,Regs);
IPXResultCode := 0;
End;
Procedure AESCancelEvent (Var AES: AESRec);
Begin
ClearRegs;
With Regs do
Begin
Bx := $0006;
Es := Seg(AES);
Si := Ofs(AES);
End;
Intr($7A,Regs);
IPXResultCode := Lo(Regs.Ax);
End;
Procedure AESStartEvent (EventNo,DelayTime: Word);
Begin
If EventNo>MaxAESEvents then {Out of range...}
Begin
IPXResultCode := 2;
Exit;
End;
FillChar(AES_ECB[EventNo],SizeOf(AES_ECB[EventNo]),0);
With AES_ECB[EventNo] do
Begin
ESRAddr[1] := 0; {ESRs not implemented...}
ESRAddr[2] := 0; {... at this time ......}
End;
AESScheduleEvent(AES_ECB[EventNo],DelayTime);
End;
Procedure AESABortEvent (EventNo: Word);
Begin
If EventNo>MaxAESEvents then {Out of range...}
Begin
IPXResultCode := 2;
Exit;
End;
ClearRegs;
With Regs do
Begin
Bx := $0006;
Es := Seg(AES_ECB[EventNo]);
Si := Ofs(AES_ECB[EventNo]);
End;
Intr($7A,Regs);
IPXResultCode := Lo(Regs.Ax);
End;
Function AESEventTrip (EventNo: Word): Boolean;
Begin
If EventNo>MaxAESEvents then {Out of range...}
Begin
IPXResultCode := 2;
AESEventTrip := False;
Exit;
End;
AESEventTrip := (AES_ECB[EventNo].InUse=0);
End;
{ * Unit Initialization * }
Begin
IPXDataSeg := Seg(IPXResultCode); {Initialize Unit's DS segment base}
IPXResultCode := 0;
IPXTransTime := 0;
FillChar(AES_ECB,SizeOf(AES_ECB),0);
End.